<?php

/*-----------------------------------------------------------------------------------*/
/* Head Hook
/*-----------------------------------------------------------------------------------*/

function of_head() { do_action( 'of_head' ); }

/*-----------------------------------------------------------------------------------*/
/* Set the default content width */
/*-----------------------------------------------------------------------------------*/

if ( ! isset( $content_width ) ) 
$content_width = 900;

/*-----------------------------------------------------------------------------------*/
/* Add default options after activation */
/*-----------------------------------------------------------------------------------*/
if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php?page=siteoptions" ) {
	//Call action that sets
	add_action('admin_head','of_option_setup');
}

function of_option_setup(){

	//Update EMPTY options
	$of_array = array();
	add_option('of_options',$of_array);

	$template = get_option('of_template');
	$saved_options = get_option('of_options');
	
	foreach($template as $option) {
		if($option['type'] != 'heading'){
			$id = $option['id'];
			$std = $option['std'];
			$db_option = get_option($id);
			if(empty($db_option)){
				if(is_array($option['type'])) {
					foreach($option['type'] as $child){
						$c_id = $child['id'];
						$c_std = $child['std'];
						update_option($c_id,$c_std);
						$of_array[$c_id] = $c_std; 
					}
				} else {
					update_option($id,$std);
					$of_array[$id] = $std;
				}
			}
			else { //So just store the old values over again.
				$of_array[$id] = $db_option;
			}
		}
	}
	update_option('of_options',$of_array);
}

/*-----------------------------------------------------------------------------------*/
/* Admin Backend */
/*-----------------------------------------------------------------------------------*/
function siteoptions_admin_head() { 
//Message on theme activation
?>

<script type="text/javascript">
jQuery(function(){
var message = '<p><strong>Architec took care of your wordpress.</strong> You can customize your theme by going to <a href="<?php echo admin_url('admin.php?page=siteoptions'); ?>">Appearance > Architec Options</a>.</p>';
jQuery('.themes-php #message2').html(message);

});
</script>
    
    
    <?php }

add_action('admin_head', 'siteoptions_admin_head');

/*-----------------------------------------------------------------------------------*/
/* Change th_excerpt length */
/*-----------------------------------------------------------------------------------*/

add_filter('excerpt_length', 'my_excerpt_length');
function my_excerpt_length($length) {
return 6; } 

?>